import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;

public class TestString {
    public static void main(String[] args) {
        char[] str = {'a','B','c','G','y'};
        MyString string = new MyString(str);
        System.out.println(string.charAt(0));
        System.out.println(string.length());
        System.out.println(string.substring(1,3));
        System.out.println(string.toLowerCase());
        char[] str1 = {'a','b','c','G','y'};
        MyString string2 = new MyString(str);
        System.out.println(string.equals(string2));
        MyString string3 = MyString.valueOf(123);
        System.out.println(string3);
    }
}

final class MyString{
    private final char[] string ;

    public MyString(char[] string) {
        this.string = string;
    }

    public char charAt(int index){
        return string[index];
    }

    public int length(){
        return string.length;
    }

    public MyString substring(int beging,int end){
        char[] str = new char[end - beging + 1];
        for(int i = 0; i < end - beging + 1; i++)
        {
            str[i] = string[i + beging];
        }
        MyString substr = new MyString(str);
        return substr;
    }

    public MyString toLowerCase(){
        char[] str = new char[string.length];
        for(int i = 0; i < string.length; i++)
        {
            if(string[i] >= 'A' && string[i] <= 'Z')
                str[i] = (char)(string[i] + 32);
            else
                str[i] = string[i];
        }
        MyString str1 = new MyString(str);
        return str1;
    }

    public boolean equals(MyString s){
        if(string.length != s.length())
            return false;
        for(int i = 0; i < string.length; i++)
        {
            if(string[i] != s.string[i])
                return false;
        }
        return true;
    }

    public static MyString valueOf(int i){
        String string = String.valueOf(i);
        char[] str = string.toCharArray();
        MyString mystring = new MyString(str);
        return mystring;
    }

    @Override
    public String toString() {
        String str = new String(string);
        return str;
    }
}